﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExtAspNet;

namespace HY.WEB.SA
{
    public partial class zj_edit : PageBase
    {

        string sid = "";
        public string us,um,tab="zj";
        public BLL.SC.zhongjie jbs = new BLL.SC.zhongjie();

        protected void Page_Load(object sender, EventArgs e)
        {
            us = Session["ID"].ToString();
            um = Session["user"].ToString();
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request["sid"]))
                {
                    sid = Request["sid"].Trim();

                    hidsid.Text = sid;
                 
                    BindText(sid);
                }
             
            }

        }
     
        void BindText(string sid)
        {
            DataTable dt = jbs.GetList("sid=" + sid).Tables[0];

            if (dt.Rows.Count > 0)
            {
                hidsid.Text = dt.Rows[0]["sid"].ToString();
                hidbh.Text = dt.Rows[0]["zbh"].ToString();

                zname.Text = dt.Rows[0]["zname"].ToString();
                zaddress.Text = dt.Rows[0]["zaddress"].ToString();

                memo.Text = dt.Rows[0]["sales"].ToString();
                area.Text = dt.Rows[0]["area"].ToString();


                person.Text = dt.Rows[0]["person"].ToString();
                tel.Text = dt.Rows[0]["tel"].ToString();

                fax.Text = dt.Rows[0]["fax"].ToString();
                QQ.Text = dt.Rows[0]["QQ"].ToString();
                email.Text = dt.Rows[0]["email"].ToString();

                msn.Text = dt.Rows[0]["msn"].ToString();
                mtel.Text = dt.Rows[0]["mtel"].ToString();

                txtjob.Text = dt.Rows[0]["pjob"].ToString();
                txtsex.Text = dt.Rows[0]["psex"].ToString();
                txtsize.Text = dt.Rows[0]["psize"].ToString();

            }

        }

   


      
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Model.SC.zhongjie jb = new Model.SC.zhongjie();

            jb.sid = int.Parse(hidsid.Text);
            jb.zbh = hidbh.Text;
            
            if (jb.zbh == "") return;
            
            jb.zname = zname.Text;
            jb.zaddress = zaddress.Text;
            jb.memo = memo.Text;
            jb.area = area.Text;
            jb.person = person.Text;
            jb.tel = tel.Text;
            jb.fax = fax.Text;
            jb.qq = QQ.Text;
            jb.email = email.Text;
            jb.mtel = mtel.Text;
            jb.msn = msn.Text;
            jb.pjob = txtjob.Text;
            jb.psex = txtsex.Text;
            jb.psize = txtsize.Text;

            BLL.SC.zhongjie sco = new BLL.SC.zhongjie();
            
            sco.Update(jb);


            //更新业务员操作记录
            BLL.Bllbase.update_rec(tab, um, " zbh='" + jb.zbh + "' ");

            Alert.Show("修改完成 ");
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
       
        }

       
    }
}